package com.netty.server.processor.up;

import com.netty.server.cmd.ByteCmd;
import com.netty.server.cmd.ByteResCmd;

/**
 * @author: 王霄
 * @date: 2022/1/18 14:17
 **/
public abstract class DefaultUpPlugin implements UpPlugin<ByteResCmd> {

    protected abstract void handler(byte[] body);

    @Override
    public void processor(ByteCmd byteCmd) {
        CmdContext.set(byteCmd.getCmdId());
        try {
            handler(byteCmd.getBody());
        } finally {
            CmdContext.remove();
        }
    }
}
